package cn.wolfcode.p2p.business.service.impl;
import java.util.Date;
import cn.wolfcode.p2p.base.domain.LoginInfo;

import cn.wolfcode.p2p.business.domain.BidRequest;
import cn.wolfcode.p2p.business.domain.BidRequestAuditHistory;
import cn.wolfcode.p2p.business.mapper.BidRequestAuditHistoryMapper;
import cn.wolfcode.p2p.business.service.IBidRequestAuditHistoryService;
import cn.wolfcode.p2p.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BidRequestAuditHistoryServiceImpl implements IBidRequestAuditHistoryService {
        @Autowired
        private BidRequestAuditHistoryMapper bidRequestAuditHistoryMapper;
        @Override
        public void save(BidRequest bidRequest, String remark, Integer state, int auditype) {
                BidRequestAuditHistory bidRequestAuditHistory = new BidRequestAuditHistory();
                bidRequestAuditHistory.setRemark(remark);
                bidRequestAuditHistory.setAuditTime(new Date());
                bidRequestAuditHistory.setApplyTime(bidRequest.getApplyTime());
                bidRequestAuditHistory.setAuditor(UserContext.getLoginInfo());
                bidRequestAuditHistory.setApplier(bidRequest.getCreateUser());
                bidRequestAuditHistory.setState(state);
                bidRequestAuditHistory.setBidRequestId(bidRequest.getId());
                bidRequestAuditHistory.setAuditType(auditype);
                bidRequestAuditHistoryMapper.insert(bidRequestAuditHistory);

        }
}
